From 4a009b08063923b6d7d326f19c2da951fceb0454 Mon Sep 17 00:00:00 2001 From: robertlipe Date: Mon, 22 Jul 2013 04:44:06 +0000 Subject: [PATCH] Remove the final (?) vestigest of microseconds as a separate member. Gopal was a stupid bug within gopal itself. creation_time was being written three independent times per line (sigh) and once MS quit being a separate field, it was no longer retained across writes. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4465 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/csv_util.cc | 3 ++- gpsbabel/defs.h | 2 -- gpsbabel/gopal.cc | 11 +++++++---- gpsbabel/unicsv.cc | 2 +- gpsbabel/waypt.cc | 4 +--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gpsbabel/csv_util.cc b/gpsbabel/csv_util.cc index 28185d6df..54f1d2001 100644 --- a/gpsbabel/csv_util.cc +++ b/gpsbabel/csv_util.cc @@ -1222,7 +1222,8 @@ xcsv_parse_val(const char* s, waypoint* wpt, const field_map_t* fmp, break; case XT_NET_TIME: { time_t tt = wpt->GetCreationTime(); - dotnet_time_to_time_t(atof(s), &tt, &wpt->microseconds); +fatal("XT_NET_TIME can't have possibly ever worked."); +// dotnet_time_to_time_t(atof(s), &tt, &wpt->microseconds); } break; case XT_GEOCACHE_LAST_FOUND: diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index d76bc974d..28529ea71 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -447,7 +447,6 @@ public: description(NULL), notes(NULL), url_next(NULL), - microseconds(0), route_priority(0), hdop(0), vdop(0), @@ -537,7 +536,6 @@ public: creation_time = creation_time.addMSecs(ms); } gpsbabel::DateTime creation_time; - int microseconds; /* Optional millionths of a second. */ /* * route priority is for use by the simplify filter. If we have diff --git a/gpsbabel/gopal.cc b/gpsbabel/gopal.cc index d24434192..710b80b84 100644 --- a/gpsbabel/gopal.cc +++ b/gpsbabel/gopal.cc @@ -52,6 +52,7 @@ #include #include "csv_util.h" #include +#include #include "strptime.h" #include "jeeps/gpsmath.h" #include "grtcirc.h" @@ -213,14 +214,13 @@ gopal_read(void) //TICK; TIME; LONG; LAT; HEIGHT; SPEED; Fix; HDOP; SAT //3801444, 080558, 2.944362, 43.262117, 295.28, 0.12964, 2, 2.900000, 3 c = csv_lineparse(str, ",", "", column++); + double millisecs = 0; while (c != NULL) { switch (column) { case 0: /* "-" */ /* unknown fields for the moment */ sscanf(c, "%lu", µsecs); - wpt->SetCreationTime(microsecs / 1000000, microsecs % 1000000); -// FIXME: this is totally papering over a problem where creation time is -// being overwritten later. -wpt->microseconds = microsecs % 1000000; + // Just save this; we'll use it on the next field. + millisecs = /*lround*/(microsecs % 1000000) / 1000.0; break; case 1: /* Time UTC */ sscanf(c,"%lf",&hmsd); @@ -233,7 +233,9 @@ wpt->microseconds = microsecs % 1000000; tm.tm_year=trackdate.tm_year; tm.tm_mon=trackdate.tm_mon; tm.tm_mday=trackdate.tm_mday; + // This will probably be overwritten by field 9...if we have 9 fields. wpt->creation_time = tx+((((time_t)tm.tm_hour * 60) + tm.tm_min) * 60) + tm.tm_sec; + wpt->creation_time = wpt->creation_time.addMSecs(millisecs); if (global_opts.debug_level > 1) { strftime(tbuffer, sizeof(tbuffer), "%c", gmtime(&wpt->creation_time)); printf("parsed timestamp: %s\n",tbuffer); @@ -292,6 +294,7 @@ wpt->microseconds = microsecs % 1000000; fatal("Bad date '%s'.\n", c); } wpt->creation_time += mkgmtime(&tm2); + wpt->creation_time = wpt->creation_time.addMSecs(millisecs); break; case 10: // Unknown. Ignored. case 11: // Bearing. Ignored. diff --git a/gpsbabel/unicsv.cc b/gpsbabel/unicsv.cc index fbc71311f..739aeceaa 100644 --- a/gpsbabel/unicsv.cc +++ b/gpsbabel/unicsv.cc @@ -1192,7 +1192,7 @@ unicsv_parse_one_line(char *ibuf) } if (msec >= 0) { - wpt->creation_time.addMSecs(msec); + wpt->creation_time = wpt->creation_time.addMSecs(msec); } if (opt_utc) { diff --git a/gpsbabel/waypt.cc b/gpsbabel/waypt.cc index eb35939c9..5c641b54c 100644 --- a/gpsbabel/waypt.cc +++ b/gpsbabel/waypt.cc @@ -669,9 +669,7 @@ waypoint::CreationTimeXML() const return NULL; } - QDateTime dt = GetCreationTime(); - dt = dt.addMSecs(MICRO_TO_MILLI(microseconds)); - dt = dt.toUTC(); + QDateTime dt = GetCreationTime().toUTC(); // qDebug() << dt.toString("dd.MM.yyyy hh:mm:ss.zzz") << " CML " << microseconds; const char* format = "yyyy-MM-ddTHH:mm:ssZ"; -- 2.30.2